    // StatusWorker.cpp
    #include "StatusWorker.h"
    #include "RobotController.h"
    #include "../global_logger.h"
    #include "SCHeadData.h"
    
    // 修改构造函数，接受 interval 参数
    StatusWorker::StatusWorker(int interval, QObject *parent) 
        : QObject(parent), m_timer(nullptr), m_interval(interval) {
        GLOBAL_LOGGER->debug("StatusWorker 初始化完成，轮询间隔: {}ms", interval);
    }
    
    StatusWorker::~StatusWorker()
    {
        GLOBAL_LOGGER->debug("销毁 StatusWorker");
        stop();
    }
    
    void StatusWorker::start() {
        GLOBAL_LOGGER->info("启动状态轮询定时器，间隔: {}ms", m_interval);
        
        // 在工作线程中创建并启动定时器
        m_timer = new QTimer(); // 不设置父对象，避免跨线程问题    
        m_timer->setInterval(m_interval);  // 使用构造函数传入的间隔时间
        connect(m_timer, &QTimer::timeout, this, &StatusWorker::onTimeout);
        m_timer->start();
        
        GLOBAL_LOGGER->debug("状态轮询定时器已启动");
    }
    
    void StatusWorker::stop() {
        if (m_timer) {
            if (m_timer->isActive()) {
                m_timer->stop();
                GLOBAL_LOGGER->debug("状态轮询定时器已停止");
            }
            delete m_timer;
            m_timer = nullptr;
        }
    }
    
    void StatusWorker::onTimeout() {
        GLOBAL_LOGGER->trace("状态轮询定时器超时，发送状态请求");
        emit requestBattery(CMD_STATE_GET_BATTERY);
        emit requestPosition(CMD_STATE_GET_POSITION);
        emit requestNavState(CMD_STATE_GET_NAVIGATIONAL_STATE);
    }